package com.mylove.textprogressbar;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RelativeLayout;

import com.mylove.textprogressbar.callback.IRefreshHead;
import com.mylove.textprogressbar.util.DensityUtils;

/**
 * @author myLove
 * @time 2017/12/29 17:09
 * @e-mail love@yanyi.red
 * @overview 默认头部view
 */

public class DefaultHeadView2 extends RelativeLayout implements IRefreshHead {
    private int height = (int) DensityUtils.dipToPx(getContext(), 60);

    public DefaultHeadView2(Context context) {
        super(context);
        init(context);
    }

    public DefaultHeadView2(Context context, AttributeSet attrs) {
        super(context, attrs);
        init(context);
    }

    public DefaultHeadView2(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        init(context);
    }


    private void init(Context context) {
        View mView = LayoutInflater.from(context).inflate(R.layout.default_layout, null);
        ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, height);
        addView(mView, params);
    }


    /**
     * 开始下拉
     */
    @Override
    public void onStart() {
    }

    /**
     * 下拉中 多次被调用
     *
     * @param distance 头布局距离顶部的距离
     */
    @Override
    public void onPullDown(int distance) {
    }

    /**
     * 松手 多次被调用
     *
     * @param distance 头布局距离顶部的距离
     */
    @Override
    public void onFingerUp(int distance) {
//        barView.setNum(num1, num2, num3)
//                .setSize(size)
//                .setTime(time)
//                .start();
    }

    /**
     * 结束
     */
    @Override
    public void onStop() {
    }

    @Override
    public int headViewHeight() {
        return height + 10;
    }
}
